package cn.zz.veggie.application.assembler;

import java.util.List;

import cn.zz.comm.util.DateTimeUtil;
import cn.zz.veggie.model.domain.Quote;
import cn.zz.veggie.model.query.QuoteQuery;
import cn.zz.veggie.web.types.dto.mgmt.MgmtQuoteQueryDto;
import cn.zz.veggie.web.types.dto.mgmt.MgmtUserQuoteSaveDto;

/**
 * @author zhongq
 * @since 2024/5/22
 */
public class UserQuoteAssembler {
	public static QuoteQuery buildAdminQuery(MgmtQuoteQueryDto dto, List<Integer> productIds) {
		QuoteQuery query = new QuoteQuery();
		query.setUid(dto.getUid());
		query.setPids(productIds);
		return query;
	}

	public static Quote createOrUpdate(Quote quote, MgmtUserQuoteSaveDto dto) {
		if (quote == null) {
			quote = new Quote();
			quote.setPid(dto.getPid());
			quote.setUid(dto.getUid());
			quote.setCreatedAt(DateTimeUtil.unixTime());

		}
		quote.setUpdatedAt(DateTimeUtil.unixTime());
		quote.setPrice(dto.getPrice());
		return quote;
	}
}